package ryarithsGame;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

//import jmetest.TutorialGuide.HelloModelLoading;

import com.jme.bounding.BoundingSphere;
import com.jme.scene.Node;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.MaxToJme;

public class Aimer extends Node
{
	
	  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Logger logger = Logger.getLogger(Aimer.class.getName());

	public Aimer(String name) {
	        super(name);
	        loadAimer();
	    }
	
	  private void loadAimer()
	  {
		  URL model=Aimer.class.getClassLoader().getResource("data/models/aimer.3ds");

	        // Create something to convert .obj format to .jme
	        FormatConverter converter=new MaxToJme();
	        // Point the converter to where it will find the .mtl file from
	       // converter.setProperty("mtllib",model);

	        // This byte array will hold my .jme file
	        ByteArrayOutputStream BO=new ByteArrayOutputStream();
	        try {
	            // Use the format converter to convert .obj to .jme
	            converter.convert(model.openStream(), BO);
	            Node aimer=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
	            // shrink this baby down some
	            aimer.setLocalScale(.04f);
	            aimer.setModelBound(new BoundingSphere());
	            aimer.updateModelBound();
	            // Put her on the scene graph
	            
	            
	            this.attachChild(aimer);
	        } catch (IOException e) {
	        	//    Just in case anything happens
	            logger.logp(Level.SEVERE, this.getClass().toString(),
	                    "simpleInitGame()", "Exception", e);
	            System.exit(0);
	        }
		  
	  }
	
	
}